home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2614.ZIP
/
TBROWS.ZIP
/
TTBR8.PRG
< prev
next >
Wrap
Text File
|
1990-10-26
|
4KB
|
191 lines
/*****
*
* TTBR8.PRG
* Eighth example for TBROWSE class using a database file
*
* 22 October 90
* Luiz Quintela - Nantucket Corp
*
* Clipper ttbr8 /N/W/A/B
* RTLINK FILE ttbr8 PLL base50
*
*/
// Include Header Files
#include "inkey.ch"
#include "setcurs.ch"
MEMVAR GetList
FUNCTION Main()
LOCAL b, column, nKey, aColors, nCnt, aLowHi
SET SCOREBOARD OFF
SET DATE BRITISH
SET CONFIRM ON
USE test INDEX test NEW
// Turn cursor off
SETCURSOR(SC_NONE)
SETCOLOR( "BG/B" ); CLS
b := TBrowseDB( 2, 2, 20, 48)
b:colorSpec := "BG/B,GR+/R,W/N,N,GR+/W,W+/B,R+/B,GR+/B"
b:colSep := " │ "
b:headSep := "═╤═"
b:footSep := "═══"
// TBColumn objects
column := TBColumnNew( "Field 1", {|| test->fld1} )
column:footing := "First"
b:addColumn( column )
column := TBColumnNew( "Field 2", {|| test->fld2} )
b:addColumn( column )
column := TBColumnNew( "Field 3", {|| test->fld3} )
b:addColumn( column )
column := TBColumnNew( "Field 4", {|| test->fld4} )
b:addColumn( column )
column := TBColumnNew( "Field 5", {|| test->fld5} )
column:footing := "Last"
b:addColumn( column )
// Freeze one column
b:freeze := 1
// cargo
// is an instance variable of ANY DATA TYPE, allowing
// arbitrary information to be attached to a TBrowse object and
// retrieved later
// This is the same principle used in TBColumn:cargo
// But now we will use TBrowse:cargo
b:cargo := {|| ChgClr() }
WHILE .T.
IF ( b:colPos <= 1 )
b:colPos := b:freeze + 1
ENDIF
// Stabilization
WHILE ( !b:stabilize() )
nKey := InKey()
IF ( nKey != 0 )
EXIT // abort if a key is waiting
ENDIF
END
IF ( b:stable )
IF ( b:hitTop .OR. b:hitBottom )
TONE(87.3,1)
TONE(40,3.5)
ENDIF
nKey := INKEY(0)
ENDIF
// Process key
IF ( nKey == K_DOWN )
b:down()
ELSEIF ( nKey == K_UP )
b:up()
ELSEIF ( nKey == K_PGDN )
b:pageDown()
ELSEIF ( nKey == K_PGUP )
b:pageUp()
ELSEIF ( nKey == K_CTRL_PGUP )
b:goTop()
ELSEIF ( nKey == K_CTRL_PGDN )
b:goBottom()
ELSEIF ( nKey == K_RIGHT )
b:right()
ELSEIF ( nKey == K_LEFT )
b:left()
ELSEIF ( nKey == K_HOME )
b:home()
ELSEIF ( nKey == K_END )
b:end()
ELSEIF ( nKey == K_CTRL_LEFT )
b:panLeft()
ELSEIF ( nKey == K_CTRL_RIGHT )
b:panRight()
ELSEIF ( nKey == K_CTRL_HOME )
b:panHome()
ELSEIF ( nKey == K_CTRL_END )
b:panEnd()
ELSEIF ( nKey == K_ESC )
CLS; SETCURSOR(SC_NORMAL); QUIT
ELSEIF ( nKey == K_F10 )
// Evaluate attached cargo
aLowHi := EVAL( b:cargo )
// Change all colors
// Transverse all columns
// Starting at column 1 up to colCount which contains
// the total number of data columns in the browse
FOR nCnt := 1 TO b:colCount
// getColumn is a method which returns a TBColumn
// object
column := b:getColumn( nCnt )
column:defColor := { 1, 2 }
column:colorBlock := { || LineClr( aLowHi ) }
column:defColor := { 1, 2 }
b:setColumn( nCnt, column )
NEXT
b:configure() // Causes the TBrowse object to
// re-examine all instance variables and TBColumn
// objects, and them reconfigure its internal settings
// as required
b:refreshAll() // Internally marks all data rows as
// invalid, causing them to be refilled and redisplayed
// during the next stabilize loop
ENDIF
END
FUNCTION ChgClr()
LOCAL column, nLow := 1, nHi := 200
LOCAL cScr := SAVESCREEN( 7, 10, 11, 27 )
LOCAL cClr := SETCOLOR( "GR+/N,N/GR+" )
LOCAL nCurs := SETCURSOR(SC_NORMAL)
// First, ask for data rows range
@ 7,10 CLEAR TO 11,27
@ 8,12 SAY "From line:" GET nLow PICTURE "999"
@ 10,12 SAY "To line:" GET nHi PICTURE "999"
READ
SETCURSOR(nCurs)
SETCOLOR(cClr)
RESTSCREEN( 7, 10, 11, 27, cScr )
RETURN IF(LASTKEY() == 27, { 1, 200 }, { nLow, nHi } )
FUNCTION LineClr( aLowHi )
IF RECNO() >= aLowHi[1] .AND. RECNO() <= aLowHi[2]
RETURN { 6 , 2 }
ELSE
RETURN { 1, 2 }
ENDIF
/* EOF - TBBR8.PRG */